#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        int i = 0, j = 0;
        vector<int> new_num;
        while (i < m || j < n) {
            if (j == n) {
                new_num.push_back(nums1[i]);
                ++i;
            } else if (i == m) {
                new_num.push_back(nums2[j]);
                ++j;
            } else if (nums1[i] > nums2[j]) {
                new_num.push_back(nums2[j]);
                ++j;
            } else {
                new_num.push_back(nums1[i]);
                ++i;
            }
        }
        nums1.assign(new_num.begin(), new_num.end());
    }
};

int main()
{
    vector<int> nums1 = {1,2,3,0,0,0};
    vector<int> nums2 = {2,5,6};
    int m = 3, n = 3;

    Solution a;
    a.merge(nums1, m ,nums2 , n);

    for (int i = 0; i < nums1.size(); i++) {
        cout << nums1[i] << " ";
    }
    cout << endl;
}